package com.api.controller;

import com.api.domain.CodeDO;
import com.api.entity.SysCode;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

import static com.api.entity.table.SysCodeTableDef.SYS_CODE;

/**
 * @Description: 描述
 * @Author: yangshfieng
 * @CreateDate: 2023/6/25
 */
@RestController
@RequestMapping("/code")
public class CodeController {


    /**
     *  获取系统码表数据
     *
     * @param params
     * @return
     */
    @RequestMapping("/getCodeDOList")
    public List<CodeDO> getCodeDOList(@RequestParam Map<String,Object> params){
        List<CodeDO> codeDOS = SysCode.create().select(SYS_CODE.CODE_NAME,SYS_CODE.CODE_NUMBER,SYS_CODE.CODE_DESC,SYS_CODE.CODE_SORT)
                .where(SysCode::getCodeName).like(null != params.get("codeName") ? params.get("codeName").toString() : null)
                .listAs(CodeDO.class);
        return codeDOS;
    }
}
